home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Revolution - Das Atari CD Magazin 1997
/
Revolution - Das Atari CD Magazin 1.iso
/
software
/
anwendng
/
qed_397
/
sourcen
/
text.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-01-04
|
4KB
|
177 lines
#include "global.h"
#include "find.h"
#include "mintlib.h"
#include "qed.h"
#include "set.h"
#include "text.h"
/* ------------------------------------------------------------------ */
/* Trash : 1
* Clipbrd : 1
* Projekt : 8
* Text : 8
* Temp : 1 (für Projekt-Zwischen-Dateien)
*/
#define TEXTANZ 19
/* ------------------------------------------------------------------ */
LOCAL TEXT_INF text_inf[TEXTANZ];
LOCAL WORD last_icon = -1;
LOCAL TEXTP last_t_ptr = NULL;
LOCAL TEXTP used_list;
LOCAL TEXTP free_list;
/* ------------------------------------------------------------------ */
TEXTP get_text(WORD icon)
{
TEXTP t_ptr;
if (icon==-1) return NULL;
if (icon==last_icon) return (last_t_ptr);
for (t_ptr=used_list; t_ptr!=NULL; t_ptr=t_ptr->next)
if (t_ptr->link==icon)
{
last_icon = icon;
last_t_ptr = t_ptr;
break;
}
return t_ptr;
}
LOCAL VOID nullen(TEXTP t_ptr)
{
t_ptr->cursor_line = FIRST(&t_ptr->text);
t_ptr->file_date_time = -1L;
t_ptr->xpos = 0;
t_ptr->ypos = 0L;
t_ptr->moved = 0;
t_ptr->readonly = FALSE;
t_ptr->blink = t_ptr->block = t_ptr->block_dir = t_ptr->up_down = FALSE;
t_ptr->cursor = TRUE;
t_ptr->ending = tos;
t_ptr->namenlos = TRUE;
t_ptr->loc_opt = &loc_opt[0];
t_ptr->info_str[0] = EOS;
t_ptr->filename[0] = EOS;
}
TEXTP new_text(WORD link)
{
TEXTP t_ptr;
if (free_list==NULL)
{
free_list = (TEXTP)Malloc(sizeof(TEXT_INF));
if (free_list==NULL) return NULL;
free_list->next = NULL;
}
if (get_text(link)!=NULL) /* gleiche Nummer nochmal */
{
inote(1,FATALERR,9);
return NULL;
}
t_ptr = free_list; /* Aushängen */
free_list = t_ptr->next;
t_ptr->next = used_list; /* Einhängen */
used_list = t_ptr;
t_ptr->link = link;
init_textring(&t_ptr->text);
nullen(t_ptr);
return t_ptr;
}
VOID clear_text(TEXTP t_ptr)
{
free_textring(&t_ptr->text);
nullen(t_ptr);
}
VOID destruct_text(TEXTP t_ptr)
{
TEXTP t;
if (last_icon==t_ptr->link) last_icon = -1;
kill_textring(&t_ptr->text);
if (used_list==t_ptr)
used_list = t_ptr->next;
else
{
for (t=used_list; t->next!=t_ptr; t=t->next) ;
t->next = t_ptr->next;
}
if (t_ptr<text_inf || t_ptr>=&text_inf[TEXTANZ])
Mfree(t_ptr);
else
{
t_ptr->next = free_list;
free_list = t_ptr;
}
}
VOID set_text_name(TEXTP t_ptr, const UBYTE *filename, BOOLEAN namenlos)
{
FILENAME str;
WORD i, j;
UBYTE m[MUSTER_LEN+1];
strcpy(t_ptr->filename,filename);
t_ptr->namenlos = namenlos;
if (namenlos)
{
t_ptr->loc_opt = &loc_opt[0];
}
else
{
t_ptr->loc_opt = &loc_opt[0];
file_name(filename,str, FALSE);
j = 0;
for (i=1; i<loc_opt_anz; i++)
{
strcpy(m, muster_str[i]);
if (!caseSens((UBYTE *)filename, NULL))
str_upper(m);
if (filematch(str, m))
j = i;
}
t_ptr->loc_opt = &loc_opt[j];
}
}
VOID update_loc_opt(VOID)
{
TEXTP t_ptr;
FILENAME str;
WORD i, j;
for (t_ptr=used_list; t_ptr!=NULL; t_ptr=t_ptr->next)
if (!t_ptr->namenlos)
{
t_ptr->loc_opt = &loc_opt[0];
file_name(t_ptr->filename,str, FALSE);
j = 0;
for (i=1; i<loc_opt_anz; i++)
{
if (filematch(str, muster_str[i]))
j = i;
}
t_ptr->loc_opt = &loc_opt[j];
}
}
VOID init_text(VOID)
{
WORD i;
TEXTP t_ptr = text_inf;
used_list = NULL;
free_list = t_ptr;
for (i=TEXTANZ-1; (--i)>=0; t_ptr++)
t_ptr->next = &t_ptr[1];
t_ptr->next = NULL;
}